var t = require;
var e = module;
var o = exports;
var n =
    (this && this.__extends) ||
    (function() {
        var t = function(e, o) {
            return (t =
                Object.setPrototypeOf ||
                ({ __proto__: [] }
                    instanceof Array &&
                    function(t, e) {
                        t.__proto__ = e;
                    }) ||
                function(t, e) {
                    for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                })(e, o);
        };
        return function(e, o) {
            function n() {
                this.constructor = e;
            }
            t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
        };
    })(),
    r =
    (this && this.__decorate) ||
    function(t, e, o, n) {
        var r,
            a = arguments.length,
            i = a < 3 ? e : null === n ? (n = Object.getOwnPropertyDescriptor(e, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, o, n);
        else
            for (var s = t.length - 1; s >= 0; s--)
                (r = t[s]) && (i = (a < 3 ? r(i) : a > 3 ? r(e, o, i) : r(e, o)) || i);
        return a > 3 && i && Object.defineProperty(e, o, i), i;
    };
Object.defineProperty(o, "__esModule", { value: !0 });
var a = t("Prefabs"),
    i = t("TableRules"),
    s = t("Util"),
    c = require("./黑色遮罩"),
    l = cc._decorator,
    u = l.ccclass,
    p = l.property,
    f = (function(t) {
        function e() {
            var e = (null !== t && t.apply(this, arguments)) || this;
            return (e.zIndex = 0), (e.isMask = !1), (e.prefab = null), (e.isDestroy = !1), e;
        }
        var o;
        return (
            n(e, t),
            (o = e),
            (e.prototype.onLoad = function() {
                (this.view = o.nodes[this.res]),
                this.view ||
                    (this.prefab ?
                        ((this.view = cc.instantiate(this.prefab)), (o.nodes[this.res] = this.view)) :
                        ((this.view = a.instantiate(this.res)), (o.nodes[this.res] = this.view)),
                        this.view.getComponent(cc.Widget) ?
                        (this.view.x = this.view.y = 0) :
                        ((this.view.x = (0.5 - this.node.anchorX) * this.node.width),
                            (this.view.y = (0.5 - this.node.anchorY) * this.node.height)),
                        (this.view.width = this.node.width),
                        (this.view.height = this.node.height)),
                    (this.view.CtrlComp = this),
                    (this.view.parent = this.node),
                    this.view.on("onClick", this.onClick, this),
                    this.zIndex && (this.view.zIndex = this.zIndex),
                    this.view.emit("ViewData_Init", this);
                var t = this.view.getComponent(c.default);
                this.isMask && null == t ?
                    this.view.addComponent(c.default) :
                    !this.isMask && t && this.view.removeComponent(c.default),
                    (this.animation = this.view.getComponent(cc.Animation)),
                    this.animation ?
                    (this.aniState = this.animation.getAnimationState(this.animation.defaultClip.name)) :
                    cc.tween(this.view).set({ opacity: 1 }).to(0.1, { opacity: 255 }).start(),
                    i.TableRules.show(this.view, this.res.replace(/ /g, "_"));
            }),
            (e.prototype.onClick = function(t, e) {}),
            (e.prototype.onDestroy = function() {
                i.TableRules.hide(this.view, this.res.replace(/ /g, "_")),
                    this.isDestroy ?
                    ((o.nodes[this.res] = null), (this.view.parent = null), this.view.destroy()) :
                    (this.view.parent = null);
            }),
            (e.prototype.find = function(t) {
                return cc.find(t, this.view);
            }),
            (e.prototype.findComp = function(t, e) {
                return this.find(t).getComponent(e);
            }),
            (e.prototype.getViewComp = function(t) {
                return this.view.getComponent(t);
            }),
            (e.prototype.showLable = function(t, e) {
                s.showLable(t, this.view, e);
            }),
            (e.prototype.showView = function(t) {
                var e = this.getComponent(t);
                return (
                    null == e &&
                    (e = this.addComponent(t)).animation &&
                    (s.stopInput(),
                        (e.aniState.wrapMode = cc.WrapMode.Normal),
                        e.animation.play(),
                        e.animation.off(cc.Animation.EventType.FINISHED),
                        e.animation.once(cc.Animation.EventType.FINISHED, function() {
                            s.stopInput(!1);
                        })),
                    e
                );
            }),
            (e.prototype.hideView = function(t, e, n) {
                var r;
                return (
                    (r = t ? (t instanceof o ? t : this.getComponent(t)) : this) ?
                    r.animation ?
                    (s.stopInput(),
                        (r.aniState.wrapMode = cc.WrapMode.Reverse),
                        r.animation.play(),
                        r.animation.off(cc.Animation.EventType.FINISHED),
                        r.animation.once(cc.Animation.EventType.FINISHED, function() {
                            s.stopInput(!1), r.destroy(), e && n.call(e);
                        })) :
                    (r.destroy(), e && n.call(e)) :
                    e && n.call(e),
                    r
                );
            }),
            (e.nodes = {}),
            r([p(cc.Prefab)], e.prototype, "prefab", void 0),
            (e = o = r([u], e))
        );
    })(cc.Component);
o.default = f;